<?php

namespace App\Controller;
use Common\Controller\BaseController;
use App\Logic;

class GatheringTourController extends AppBaseController
{
    private $gatheringTourLogic;

    public function _initialize()
    {
        parent::_initialize();
        $this->gatheringTourLogic = new Logic\GatheringTourLogic();
    }

    public function getDeviceCode(){
        $this->display();
    }

    public function androidLead(){
        $this->display();
    }

    public function iphoneLead(){
        $this->display();
    }

    /**
     * 去聚享游页面
     *
     * @return void
     */
    public function goGatheringTourIndex()
    {
        $userInfo = $this->getUserInfo();
        $userId = $userInfo['id'];
        
        $deviceCode=I('post.deviceCode','','trim');
        if($this->gatheringTourLogic->get_device_type()==='ios' && strlen($deviceCode)==36){
            
        }else if($this->gatheringTourLogic->get_device_type()==='android' && strlen($deviceCode)==15){

        }
        else{
            $res = static::$res->err('设备id有误，请查看引导，android为IMEI,iphone为IDFA,当前设备为：'.$this->gatheringTourLogic->get_device_type());
            $this->ajaxReturn($res);
        }
        $url=$this->gatheringTourLogic->getRegisterUrl($userId,$deviceCode);
        if(!empty($url)){
            $res = static::$res->suc("成功", array(
            "url" => $url
            ));
            $this->ajaxReturn($res);
        }
        $res = static::$res->err('获取失败');
        $this->ajaxReturn($res);
    }

    public function receiveReward(){
        $data=I('param.');
        $logFileName = RUNTIME_PATH.'Logs/gt/'.date('Y-m-d').'.log';
        logs(array(
               'msg' => '请求入参',
                'data' => $data
            ), $logFileName);
        return $this->gatheringTourLogic->award($data);
    }

}
